package com.ruoyi.project.dict.kangxipage.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.dict.kangxipage.domain.KangxiPage;
import com.ruoyi.project.dict.kangxipage.service.IKangxiPageService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 康熙扫描页Controller
 * 
 * @author shixiangwen
 * @date 2021-04-19
 */
@Controller
@RequestMapping("/dict/kangxipage")
public class KangxiPageController extends BaseController
{
    private String prefix = "dict/kangxipage";

    @Autowired
    private IKangxiPageService kangxiPageService;

    @RequiresPermissions("dict:kangxipage:view")
    @GetMapping()
    public String kangxipage()
    {
        return prefix + "/kangxipage";
    }

    /**
     * 查询康熙扫描页列表
     */
    @RequiresPermissions("dict:kangxipage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KangxiPage kangxiPage)
    {
        startPage();
        List<KangxiPage> list = kangxiPageService.selectKangxiPageList(kangxiPage);
        return getDataTable(list);
    }

    /**
     * 导出康熙扫描页列表
     */
    @RequiresPermissions("dict:kangxipage:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(KangxiPage kangxiPage)
    {
        List<KangxiPage> list = kangxiPageService.selectKangxiPageList(kangxiPage);
        ExcelUtil<KangxiPage> util = new ExcelUtil<KangxiPage>(KangxiPage.class);
        return util.exportExcel(list, "kangxipage");
    }

    /**
     * 新增康熙扫描页
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存康熙扫描页
     */
    @RequiresPermissions("dict:kangxipage:add")
    @Log(title = "康熙扫描页", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(KangxiPage kangxiPage)
    {
        return toAjax(kangxiPageService.insertKangxiPage(kangxiPage));
    }

    /**
     * 修改康熙扫描页
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        KangxiPage kangxiPage = kangxiPageService.selectKangxiPageById(id);
        mmap.put("kangxiPage", kangxiPage);
        return prefix + "/edit";
    }

    /**
     * 修改保存康熙扫描页
     */
    @RequiresPermissions("dict:kangxipage:edit")
    @Log(title = "康熙扫描页", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(KangxiPage kangxiPage)
    {
        return toAjax(kangxiPageService.updateKangxiPage(kangxiPage));
    }

    /**
     * 删除康熙扫描页
     */
    @RequiresPermissions("dict:kangxipage:remove")
    @Log(title = "康熙扫描页", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(kangxiPageService.deleteKangxiPageByIds(ids));
    }
}
